package com.shaco.heroproject.fragmentFactory;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.shaco.heroproject.fragment.NewsLatestFragment;

public class FragmentFactory {
    private static SparseArray<Fragment> fragmentMap = new SparseArray<Fragment>();
    private static final String[] urls = {"207", "216", "261", "212", "213", "210", "214", "211"};

    public static Fragment creatFragment(int position) {
        Fragment fragment = fragmentMap.get(position);
        if (fragment == null) {
            switch (position) {
                default:
                    fragment = new NewsLatestFragment();
                    Bundle args = new Bundle();
                    args.putString("url", urls[position]);
                    fragment.setArguments(args);
                    break;
            }
            fragmentMap.put(position, fragment);
        }

        return fragment;

    }

}
